home *** CD-ROM | disk | FTP | other *** search
/ The Atari Compendium / The Atari Compendium (Toad Computers) (1994).iso / files / umich / utils / clocks / sunclock.zoo / SOURCES / SCR2.C < prev    next >
C/C++ Source or Header  |  1990-06-08  |  2KB  |  62 lines

  1. #include <stdlib.h>
  2. #include <tos.h>
  3.  
  4. #include "gem.h"
  5. #include "scr2.h"
  6.  
  7. static long *Scr2Original;                      /* Address of old screen */
  8. static long *Scr2Extra;                      /* Address of extra screen */
  9. static long *Scr2Malloc;               /* Malloc-Address of extra screen */
  10.  
  11. /*-------------------------------------------------------------------------*/
  12. /* Defines a second screen. Returns the address from the two screens.      */ 
  13. /*-------------------------------------------------------------------------*/
  14. void Scr2Init()
  15. {
  16.    Scr2Original = (long*)Physbase();
  17.    Scr2Extra = Scr2Malloc = (long*)malloc(0x7e00);  
  18.    if (!Scr2Malloc)
  19.        GemAbort("Scr2Init: memory exhausted!");
  20.  
  21.    (long)Scr2Extra += (0x100 - ((long)Scr2Malloc)%0x100);      /* Mod 256 */
  22.    Setscreen(Scr2Extra, Scr2Original, -1); 
  23. }
  24.  
  25. /*-------------------------------------------------------------------------*/
  26. /* Physbase = Logbase = original screen                       */
  27. /* extra screen is deleted.                           */
  28. /*-------------------------------------------------------------------------*/
  29. void Scr2Exit()
  30. {
  31.    /* What we see now is the extra screen, so first copy this to the other */
  32.    if (Physbase() == (void *)Scr2Extra) {
  33.       Scr2Copy();
  34.       Scr2Swap();
  35.    }
  36.    Setscreen(Scr2Original, Scr2Original, -1);
  37.    free(Scr2Malloc);
  38. }
  39.  
  40. /*-------------------------------------------------------------------------*/
  41. /* The logical and physical screens are switched.                          */
  42. /*-------------------------------------------------------------------------*/
  43. void Scr2Swap()
  44. {
  45.    Setscreen(Physbase(), Logbase(), -1);
  46. }
  47.  
  48. /*-------------------------------------------------------------------------*/
  49. /* Copies the Physical_screen to the Logical_screen. So after a            */
  50. /* switch_init, it copies the current screen to the background screen.     */
  51. /*-------------------------------------------------------------------------*/
  52. void Scr2Copy()
  53. {
  54.    register int cnt;
  55.    register long *screen1, *screen2;
  56.  
  57.    screen1 = (long *)Physbase();
  58.    screen2 = (long *)Logbase();
  59.    for (cnt=0 ; cnt<8000 ; cnt++)
  60.       *(screen2++) = *(screen1++);
  61. }
  62.